/* pointer */
#define pEXPECT(expr)                                                   \
    if ( !(expr) ) {                                                    \
        printf("\nline %d: error in \"%s\" got NULL\n",                 \
               __LINE__, # expr);                                       \
        PRINT_CLUES;                                                    \
        goto end;                                                       \
    }

/* null pointer */
#define npEXPECT(expr)                                                  \
    if ( (expr) ) {                                                     \
        printf("\nline %d: error in \"%s\" expected NULL\n",            \
               __LINE__, # expr);                                       \
        PRINT_CLUES;                                                    \
        goto end;                                                       \
    }

/* integer */
#define iEXPECT(expr,val)                                               \
    if ((value = (expr)) != (val)) {                                    \
        printf("\nline %d: error in \"%s\" got %d, expected %d\n",      \
               __LINE__, # expr, value, val);                           \
        PRINT_CLUES;                                                    \
        goto end;                                                       \
    }

/* positive integer */
#define piEXPECT(expr)                                                  \
    if ((value = (expr)) <= 0) {                                        \
        printf("\nline %d: error in \"%s\" got %d, expected >0\n",      \
               __LINE__, # expr, value);                                \
        PRINT_CLUES;                                                    \
        goto end;                                                       \
    }

/* non-positive integer ie <= 0 */
#define niEXPECT(expr)                                                  \
    if ((value = (expr)) > 0) {                                         \
        printf("\nline %d: error in \"%s\" got %d, expected <=0\n",     \
               __LINE__, # expr, value);                                \
        PRINT_CLUES;                                                    \
        goto end;                                                       \
    }

/* boolean */
#define bEXPECT(expr)                                                   \
    if ( !(expr) ) {                                                    \
        printf("\nline %d: error in \"%s\"\n",                          \
               __LINE__, # expr);                                       \
        PRINT_CLUES;                                                    \
        goto end;                                                       \
    }

/* long integer */
#define liEXPECT(expr,val)                                              \
    if ((value = (expr)) != (val)) {                                    \
        printf("\nline %d: error in \"%s\" got %d, expected %ld\n",     \
               __LINE__, # expr, value, val);                           \
        PRINT_CLUES;                                                    \
    }

/* payload counter */
#define cEXPECT(item,val)                                               \
    if ((value = ((test_payload)(item->payload))->count) != (val)) {    \
        printf("\nline %d: error in \"%s\" got %d, expected %d\n",      \
               __LINE__, # item, value, val);                           \
        PRINT_CLUES;                                                    \
    }

#define MIN(x,y) ((x)<=(y) ? (x): (y))
#define MAX(x,y) ((x)>=(y) ? (x): (y))
